package com.acheli.registry.event;

import com.acheli.registry.keybind.KeyBinding;
import com.acheli.rideable.functionLathes.ComponentFL;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.world.phys.Vec3;

import java.util.Arrays;

public class Debugging {
    public static ComponentFL cflPointer = null;
    public static boolean isTestEventMode = false;
    public static double[] testing = {0, 0, 0};
    public static int chosenIndex = 0;
    private static double num = 0.1;
    public static void run() {
        boolean keyControlDown = KeyBinding.Key_LeftCtrl.isDown() || KeyBinding.Key_RightCtrl.isDown();
        if (KeyBinding.TEST_CHANGE.consumeClick() && keyControlDown) {
            isTestEventMode = !isTestEventMode;
        }
        if (KeyBinding.TEST_X.isDown()) {
            chosenIndex=0;
        }
        if (KeyBinding.TEST_Y.isDown()) {
            chosenIndex=1;
        }
        if (KeyBinding.TEST_Z.isDown()) {
            chosenIndex=2;
        }
        if (KeyBinding.TEST_DOWN.isDown()) {
            if (KeyBinding.TEST_CHANGE.isDown()) {
                num *= 0.1;
                System.out.println("num "+num);
            } else {
                testing[chosenIndex] -= num;
                move();
            }

        }
        if (KeyBinding.TEST_UP.isDown()) {
            if (KeyBinding.TEST_CHANGE.isDown()) {
                num *= 10;
                System.out.println("num "+num);
            } else {
                testing[chosenIndex]+= num;
                move();
            }

        }
    }

    private static void move() {
        if (cflPointer != null) {
            Vec3 newPos = cflPointer.getRelativePosition()
                            .add(testing[0], testing[1], testing[2]);
            cflPointer.setRelativePosition(newPos);
            Minecraft
                    .getInstance().player
                    .sendSystemMessage(Component.literal(
                            String.valueOf(newPos)));
        } else {
            Minecraft
                    .getInstance().player
                    .sendSystemMessage(Component.literal(
                            "No focus!"
                    ));
        }
        Debugging.testing = new double[]{0, 0, 0};
    }

}
